<template>
  <button @click="getRemote">点击测试</button>
  <button @click="createWindow">打开窗口</button>
  <button @click="closeWindow">关闭窗口</button>
  <button @click="getWindow">获取窗口</button>
  <button @click="chooseDir">选择文件夹</button>
   <button @click="chooseFile">选择文件</button>
</template>

<script>
export default {
  name:'hello',
  mounted(){
    this.$main.on('hello-main',function(event,data){
      console.log(data.name)
    })
    console.log(this.$electron)
  },
  methods:{
    getRemote(){
      // this.$render.send('hello-main',{name:'hsq'})
      this.$main.test()
    },
    createWindow(){
      const winConfig = {
        width:1200,
        height:800
      }
      const divConfig = {
        name:'csdn',
        isDevTool:true
      }
     this.$main.createWindow(winConfig,'https://www.csdn.net/',divConfig)
    },
    getWindow(){
     console.log(this.$main.getWindow('csdn'))
    },
    closeWindow(){
      this.$main.closeWindow('csdn')
    },
    chooseDir(){
      console.log(this.$main.chooseDir("快快快选择一个文件夹"))
    },
    chooseFile(){
      const filters =  [
        { name: '图像', extensions: ['jpg', 'png', 'gif'] },
        { name: '视频', extensions: ['mkv', 'avi', 'mp4'] },
        { name: 'Custom File Type', extensions: ['as'] },
        { name: 'All Files', extensions: ['*'] }
      ]
      // const filters = []
      console.log(this.$main.chooseFile("选择文件",filters))
    }
  }
}
</script>

<style>

</style>